/*
    server.me -- MakeMe file for appweb server
 */

Me.load({
    targets: {
        appweb: {
            type: 'exe',
            depends: [ 'libappweb' ],
            sources: [ 'appweb.c' ],
        },

        appwebMonitor: {
            enable: "me.platform.like == 'windows'",
            type: 'exe',
            rule: 'gui',
            depends: [ 'libappweb' ],
            sources: [ 'windows/appwebMonitor.c' ],
            headers: [ 'windows/*.h' ],
            libraries: [ 'shell32.lib' ],
            resources: [ 'windows/appwebMonitor.rc' ],
        },

        'appwebMonitor.ico': {
            type: 'file',
            files: [ 'windows/appwebMonitor.ico' ],
            enable: "me.platform.like == 'windows'",
        },

        'server-cache': {
            path: 'cache',
            build: `makeDir('cache')`,
        },

        run: {
            depends: [ 'compile' ],
            run: '${BIN}/appweb --log stdout:2',
            generate: '${BIN}/appweb --log stdout:2',
        },

        rom: {
            action: "
                let files = [ '.' ]
                files += Path('web').files('**')
                files += Path('junk/static').files('**')
                files += Path('junk/db').files('*.mdb')
                files.push('appweb.conf')
                files.push('mob.conf')
                files.push('auth.conf')
                files.push('esp.conf')
                Path('romFiles.c').write(Cmd.run(['makerom', '--prefix', '/'] + files))
            ",
        },
    },
})
